﻿namespace Probel.PersonalNotes.Models.Home
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;

    public class RecordManager
    {
        #region Methods

        public StatisticsContainer GetSummaryContainer()
        {
            using (var db = new EventsDbContext())
            {
                var summary = db.GetSummary().FirstOrDefault();
                var summaryByYear = db.GetsummaryByYear().ToList();

                return new StatisticsContainer()
                {
                    Summary = summary,
                    SummaryByYear = summaryByYear,
                };
            }
        }

        public void Insert(RecordViewModel record)
        {
            using (var db = new EventsDbContext())
            {
                db.Events.Add(record);
                db.SaveChanges();
            }
        }

        #endregion Methods
    }
}